import {EventEmitter, Input, Output} from '@angular/core';
import {FormGroup} from '@angular/forms';

import {BaseComponent} from './BaseComponent';

export abstract class BaseForm extends BaseComponent {
  @Output() onOk = new EventEmitter<{ entity: any }>();
  @Output() onCancel = new EventEmitter();

  filterForm: FormGroup;
  _entity: any;

  @Input()
  get entity() {
    return this._entity;
  }

  set entity(entity: any) {
    if (this._entity === entity) {
      return;
    }
    this._entity = entity;
  }

  resetForm() {
    this.filterForm.reset(this._entity);
  }

}
